﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.AspNet.SignalR;

namespace ERPStore.Tasks.Services
{
	public class TaskConnection : PersistentConnection, ERPStore.Services.IPersistentConnection
	{
		public string GetUrl()
		{
			var url = string.Format("realtime/tasks/{0}", GlobalConfiguration.Configuration.Settings.ApiToken);
			return url;
		}

		internal static void PushMessage(string message)
		{
			var cnx = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetConnectionContext<TaskConnection>();
			if (cnx != null)
			{
				cnx.Connection.Broadcast(message);
			}
		}

	}
}
